﻿#include "OMSClientConcrete.h"

#include <Windows.h>
#include <string>

#include "soapOMSServiceSoap12Proxy.h"
#include "OMSServiceSoap12.nsmap"

OMSClientConcrete::OMSClientConcrete(void)
{
}


OMSClientConcrete::~OMSClientConcrete(void)
{
}

LRESULT OMSClientConcrete::GetServiceInfo(const std::string& serviceUrl , std::wstring& serviceInfo){
	OMSServiceSoap12Proxy sc;
	//增加这行代码，强制以UTF-8编码解码
	soap_set_mode(&sc, SOAP_C_UTFSTRING);
	//增加这行代码，使其支持SSL，不过客户端不认证
	soap_ssl_client_context(&sc, SOAP_SSL_NO_AUTHENTICATION, NULL, NULL, NULL, NULL, NULL);
	sc.soap_endpoint = serviceUrl.c_str();

	_ns1__GetServiceInfo req;
	_ns1__GetServiceInfoResponse res;


	LONG lResult = sc.GetServiceInfo(&req, &res);
	serviceInfo = *res.GetServiceInfoResult;

	return lResult;
}

LRESULT OMSClientConcrete::GetUserInfo(const std::string& serviceUrl , const std::wstring& requestData , std::wstring& userInfo){
	OMSServiceSoap12Proxy sc;
	sc.soap_endpoint = serviceUrl.c_str();

	_ns1__GetUserInfo req;
	_ns1__GetUserInfoResponse res;

	req.xmsUser = &(std::wstring)requestData;
	LONG lResult = sc.GetUserInfo(&req, &res);
	userInfo = *res.GetUserInfoResult;

	return lResult;
}

LRESULT OMSClientConcrete::SendSMS(const std::string& serviceUrl , const std::wstring& smsData , std::wstring& responseData){

	//TODO

	return 0;
}
